using System.Windows;
using System.Collections.Generic;

namespace Silvery.Logs
{
    public sealed class NErrorMessage : List<LogItem>
    {
        static NErrorMessage _Current;
        public static NErrorMessage Current
        {
            get
            {
                if (_Current == null)
                    _Current = new NErrorMessage();
                return _Current;
            }
        }
        public bool IsMessageBox { get; set; }
        private NErrorMessage()
        {
#if DEBUG
            IsMessageBox = true;
#else
            IsMessageBox = false;
#endif
        }
        /// <summary>
        /// 添加调试日志信息
        /// </summary>
        /// <param name="message"></param>
        /// <param name="classname"></param>
        public void Add(string message, string classname)
        {
            base.Add(new LogItem() { ClassName = classname, Message = message });
            if (IsMessageBox)
                MessageBox.Show("来自" + classname + ":" + message);
        }
        public void Add(string message, object sender)
        {
            Add(message, sender.GetType().Name);
        }
    }
}
